﻿@page
@model ToolGood.SqlOnline.Pages.Admins.MachineCode.ListModel
@{
	Layout = "~/Pages/Shared/_Layout_List.cshtml";
}
<div style="overflow: hidden;">
 <div class="data-header">
  <div class="search-v2">
            <form onsubmit="javascript:return false;" >
	<div class="filter">
	 <label class="label">机器码：</label>
	 <input type="text" class="text" id="txt_machineCode" autocomplete="off">
	</div>
	<div class="filter">
	 <label class="label">登录名：</label>
	 <input type="text" class="text" id="txt_name" autocomplete="off">
	</div>
	<div class="filter">
	 <label class="label">工号：</label>
	 <input type="text" class="text" id="txt_jobNo" autocomplete="off">
	</div>
	<div class="filter">
	 <label class="label">姓名：</label>
	 <input type="text" class="text" id="txt_trueName" autocomplete="off">
	</div>
	<div class="filter">
	 <button type="button" class="layui-btn layui-btn-xs layui-btn-normal search-btn">&nbsp; 搜索 &nbsp; </button>
	 <button type="button" class="layui-btn layui-btn-xs layui-btn-primary" onclick="pageReload()">&nbsp; 重置 &nbsp; </button>
	</div>
				@if (Model.ButtonPass.CanEdit)
				{
		<div class="filter"> | </div>
		<div class="filter">
		 <a href="./Binding?w=500&h=400" class="layui-btn layui-btn-xs layui-btn-primary openwin" title="绑定机器码"> &nbsp; 绑定机器码 &nbsp; </a>
		</div>
				}

   </form>

  </div>
 </div>
 <div class="data-content">
  <table class="layui-hide" id="dataList" lay-filter="dataList"></table>
 </div>
</div>
<form id="delete-form" class="hidden">
    @Html.AntiForgeryToken()
    <input type="hidden" name="id" value="" />
</form>
<script type="text/template" id="bar">
	@if (Model.ButtonPass.CanDelete)
	{
	   <a href="javascript:deleteItem({{ d.id }},'{{ d.adminName }}','{{ d.machineCode }}');">删除</a>
	}
</script>
@section js{
<script>
    var showBar = '@(Model.ButtonPass.CanEditOrDelete?"1":"0")';
	function deleteItem(id, name,machineCode) {
            $("#delete-form input[name=id]").val(id);
            layer.confirm('解除账号【' + name + "】与【"+machineCode+"】的绑定关系吗？", function (index) {
                var url = "./Ajax/DeleteAdminMachineCode";
                $.adminModePost(url, $("#delete-form").serializeJson(), function () { location.reload(); });
                layer.close(index);
            })
        }
        layui.use(["layer", "form", "table"], function () {
            var getListUrl = './Ajax/GetAdminMachineCodeList';
            var cols = [];
            //cols.push({ checkbox: true, fixed: true });
			cols.push({ field: 'id', title: '序号', width: "80"   });
			cols.push({ field: 'machineCode', title: '机器码', width: "300", sort: true, });
			cols.push({ field: 'adminName', title: '登录名', width: "120", });
			cols.push({ field: 'adminJobNo', title: '工号', width: "120", });
			cols.push({ field: 'adminTrueName', title: '姓名', width: "120", });
			if (showBar == '1') {
				cols.push({ field: 'right', title: '操作', width: "80", align: 'center', fixed: 'right', toolbar: '#bar' });
			}

            var tableOptions = {
                useRsa: true,
                url: getListUrl,
                size: 'sm',
                even: true,
                method: 'POST',
                cols: [cols],
                page: true,
                limit: 30,
                limits: [10, 20, 30, 50, 100],
                response: {statusCode:1,msgName: 'message'},
                height: 'full-' + ($('.data-header').outerHeight(true) + 5),
                done: function () { layer.closeAll('loading'); },
                request: { pageName: 'pageIndex', limitName: 'pageSize' },
                text: { none: '<span style="color:red;">暂无记录</span>' }
            };

            var layer = layui.layer, table = layui.table;
            layer.load(2);
            table.init('dataList', tableOptions);
            table.on('sort(dataList)', function (obj) {
                table.reload("dataList", { initSort: obj, where: { field: obj.field, order: obj.type }, page: { curr: 1 } });
            });

            table.on('rowDouble(dataList)', function (obj) {
                var tr = obj.tr[0];
                $(tr).find("a[edit]").trigger("click");
            });


            $('.search-btn').click(function (event) {
                layer.load(2);
                event && event.stopPropagation();
                table.reload("dataList", {
                    where: {
                        name: $("#txt_name").val(),
                        truename: $("#txt_truename").val(),
                        phone: $("#txt_phone").val(),
                        groupId: $("#sel_groupId").val(),
                    }
                    , page: { curr: 1 }
                });
                return false;
            });

        });
        function pageReload() {
            location.reload();
        }
        function reload() {
            layui.table.reload("dataList");
        }

 
</script>
}




